package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhFoundations;
import com.yinhe.system.service.IYhFoundationsService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 技术基础Controller
 * 
 * @author yinhe
 * @date 2022-09-24
 */
@RestController
@RequestMapping("/system/foundations")
public class YhFoundationsController extends BaseController
{
    @Autowired
    private IYhFoundationsService yhFoundationsService;

    /**
     * 查询技术基础列表
     */
    @PreAuthorize("@ss.hasPermi('system:foundations:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhFoundations yhFoundations)
    {
        startPage();
        List<YhFoundations> list = yhFoundationsService.selectYhFoundationsList(yhFoundations);
        return getDataTable(list);
    }

    /**
     * 导出技术基础列表
     */
    @PreAuthorize("@ss.hasPermi('system:foundations:export')")
    @Log(title = "技术基础", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhFoundations yhFoundations)
    {
        List<YhFoundations> list = yhFoundationsService.selectYhFoundationsList(yhFoundations);
        ExcelUtil<YhFoundations> util = new ExcelUtil<YhFoundations>(YhFoundations.class);
        util.exportExcel(response, list, "技术基础数据");
    }

    /**
     * 获取技术基础详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:foundations:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhFoundationsService.selectYhFoundationsById(id));
    }

    /**
     * 新增技术基础
     */
    @PreAuthorize("@ss.hasPermi('system:foundations:add')")
    @Log(title = "技术基础", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhFoundations yhFoundations)
    {
        return toAjax(yhFoundationsService.insertYhFoundations(yhFoundations));
    }

    /**
     * 修改技术基础
     */
    @PreAuthorize("@ss.hasPermi('system:foundations:edit')")
    @Log(title = "技术基础", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhFoundations yhFoundations)
    {
        return toAjax(yhFoundationsService.updateYhFoundations(yhFoundations));
    }

    /**
     * 删除技术基础
     */
    @PreAuthorize("@ss.hasPermi('system:foundations:remove')")
    @Log(title = "技术基础", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhFoundationsService.deleteYhFoundationsByIds(ids));
    }
}
